package LearnDataStructure.d_图结构;

/**
 * @version: 1.0
 * @Author: wuqiu
 * @date: 2023-07-14 12:46
 * @description: LeetcodeLearnAlgorithm -> LearnDataStructure.d_图结构
 */
public class GraphNode_EdgeSet<T> implements Comparable<GraphNode_EdgeSet<T>> {
    public T start = null;
    public T end = null;
    public int distance = 0;

    public GraphNode_EdgeSet(T start, T end, int distance) {
        this.start = start;
        this.end = end;
        this.distance = distance;
    }

    /**
     * 按权值从小到大排序
     * @param other
     * @return
     */
    @Override
    public int compareTo(GraphNode_EdgeSet<T> other) {
        int otherDistance = other.distance;
        int result = 0;
        if (this.distance > otherDistance) {
            result = 1;
        } else if (this.distance < otherDistance) {
            result = -1;
        }
        return result;
    }

    @Override
    public String toString() {
        return start + " -> " + end + " : " + distance;
    }
}
